/*
 * Copyright 2011 Powersi. All rights reserved.
 */
package com.powersi.sample.action;

import com.powersi.hygeia.web.BaseAction;
import com.powersi.sample.dao.SampleDAO;
import com.powersi.sys.util.DataGridHelper;
import com.powersi.sys.util.PagerHelper;

/**
 * The Class SampleAction.
 */
public class SampleAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Query catalog.
	 * 
	 * @return the string
	 */
	public String queryCatalog() {
		try {
			String centerId = getParameter("centerid");
			String queryType = getParameter("searchType");
			String queryValue = getParameter("searchTerm");

			SampleDAO dao = getBean(SampleDAO.class);

			PagerHelper.initPagination(getRequest());
			DataGridHelper.render(getResponse(), PagerHelper
					.getPaginatedList(dao.queryCatalog(centerId, queryType,
							queryValue)));
		} catch (Exception ex) {
			saveError(ex);
		}
		return NONE;
	}
	
	/**
	 * Query codetable.
	 *
	 * @return the string
	 */
	public String queryCodetable() {
		try {
			SampleDAO dao = getBean(SampleDAO.class);

			PagerHelper.initPagination(getRequest());
			DataGridHelper.render(getResponse(), PagerHelper
					.getPaginatedList(dao.queryCodetable(getAllParameters())));
		} catch (Exception ex) {
			saveError(ex);
		}
		return NONE;
	}
}
